/*
 * @Author: ylq
 * @Date: 2022-09-22 11:08:26
 * @Desc: 全局配置store
 * @Last Modified by: ylq
 * @Last Modified time: 2022-11-23 12:14:17
 */

import { defineStore } from 'pinia';
import LAYOUT_CONFIG from '@/config/layout';

const useAppStore = defineStore('app', {
  state: () => ({
    ...LAYOUT_CONFIG
  }),

  actions: {
    // Update app settings
    updateSettings(partial) {
      this.$patch(partial);
    },

    // Change theme color
    toggleTheme(dark) {
      console.log(dark);
      if (dark) {
        this.theme = 'dark';
        console.log(this.theme);
        document.body.setAttribute('arco-theme', 'dark');
      } else {
        this.theme = 'light';
        document.body.removeAttribute('arco-theme');
      }
    },
    toggleMenu(value) {
      this.hideMenu = value;
    }
  }
});

export default useAppStore;
